package com.kc.gb.device.plugins.camera.listener;

import com.kc.gb.device.plugins.camera.listener.support.CameraPublishEvent;
import com.kc.gb.device.plugins.camera.service.CameraMQService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.EventListener;

import javax.annotation.Resource;

@Slf4j
@Configuration
public class CameraEventListener {
    @Resource
    CameraMQService cameraMQService;

    @EventListener(CameraPublishEvent.class)
    public void listenCameraPublishEvent(CameraPublishEvent event) throws Exception {
        log.info("CameraPublishEvent:{}",event);
        try {
            cameraMQService.sendFeedBackMessage(event);
        } catch (Exception e) {
            log.error("CameraPublishEvent:{}",e.getMessage(),e);
        }
    }
}
